package com.wuxi.zhang.collection;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author wheat on 2019/12/20.
 */
public class HashMapTest {

    public static void main(String[] args) {

        Map<String, String> map = new HashMap();
        map.put("1", "A");
        map.put("2", "B");
        map.put("3", "C");
        map.put("4", "D");

        //遍历1
        for (String s : map.keySet()) {
            System.out.println("key=" + s + ",value=" + map.get(s));
        }


        //遍历2
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry entry : entries) {
            System.out.println("key=" + entry.getKey() + ",value=" + entry.getValue());
        }

    }
}
